package com.example.composableexample.navigaitonbar

import androidx.compose.foundation.clickable
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Favorite
import androidx.compose.material.icons.filled.Star
import androidx.compose.material3.Icon
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import com.example.composableexample.ui.theme.ComposableExampleTheme


@Preview
@Composable
fun NavigationBarSimple() {
    ComposableExampleTheme {
        var selectedItem by remember {
            mutableStateOf(0)
        }
        val items = listOf("Java", "Kotlin", "Android", "Compose")
        NavigationBar {
            items.forEachIndexed { index, item ->
                NavigationBarItem(
                    selected = selectedItem == index,
                    onClick = { selectedItem = index },
                    icon = {
                        Icon(imageVector = Icons.Default.Favorite, contentDescription = item)
                    },
                    label = { Text(text = item) }
                )
            }
        }
    }
}

@Preview
@Composable
fun NavigationBarWithOnlySelectedLabelsSimple() {
    var selectedItem by remember {
        mutableStateOf(0)
    }
    val items = listOf("Java", "Kotlin", "Android", "Compose")
    NavigationBar {
        items.forEachIndexed { index, item ->
            NavigationBarItem(
                selected = selectedItem == index,
                onClick = { selectedItem = index },
                icon = {
                    Icon(imageVector = Icons.Default.Star, contentDescription = item)
                },
                label = {
                    Text(text = item)
                },
                alwaysShowLabel = false
            )
        }
    }
}